package com.mall4j.cloud.user.mapper;

import com.mall4j.cloud.user.model.UserBalance;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserBalanceMapper {
    @Select("SELECT * FROM user_balance WHERE user_id = #{userId}")
    UserBalance getByUserId(Long userId);

    @Update("UPDATE user_balance SET balance = #{balance} WHERE user_id = #{userId}")
    void update(UserBalance userBalance);

    @Insert("INSERT INTO user_balance (user_id, balance) " +
            "VALUES (#{userId},  #{balance})")
    @Options(useGeneratedKeys = true, keyProperty = "balId")
    void save(UserBalance userBalance);

    // 其他数据库操作方法
}
